﻿namespace Pub.Class
{
    using System;
    using System.Collections.Generic;

    public static class InsertionSorter<T> where T: IComparable
    {
        public static void Sort(IList<T> list, bool isAsc)
        {
            for (int i = 1; i < list.Count; i++)
            {
                T local = list[i];
                if (!isAsc)
                {
                    goto Label_0050;
                }
                int num = i - 1;
                goto Label_002C;
            Label_0018:
                list[num + 1] = list[num];
                num--;
            Label_002C:
                if (num >= 0)
                {
                    T local2 = list[num];
                    if (local2.CompareTo(local) > 0)
                    {
                        goto Label_0018;
                    }
                }
                goto Label_008D;
            Label_0050:
                num = i - 1;
                goto Label_006A;
            Label_0056:
                list[num + 1] = list[num];
                num--;
            Label_006A:
                if (num >= 0)
                {
                    T local3 = list[num];
                    if (local3.CompareTo(local) < 0)
                    {
                        goto Label_0056;
                    }
                }
            Label_008D:
                list[num + 1] = local;
            }
        }
    }
}

